(** 
    Mlib.mli 
    A general library for the project. You will find i/o operations functions,
    global variables and useful functions.
    Bozman Çagdas <bozman.cagdas@gmail.com> - 2011
    Razakamiadana Tefin <tefy.razaka@gmail.com>   - 2011
*)

val debug : ('a, out_channel, unit) format -> 'a

(** **** A simple set of string **** *)
module Set : sig
    type elt = String.t
    type t
    val empty : t
    val is_empty : t -> bool
    val mem : elt -> t -> bool
    val add : elt -> t -> t
    val singleton : elt -> t
    val remove : elt -> t -> t
    val union : t -> t -> t
    val inter : t -> t -> t
    val diff : t -> t -> t
    val compare : t -> t -> int
    val equal : t -> t -> bool
    val subset : t -> t -> bool
    val iter : (elt -> unit) -> t -> unit
    val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
    val for_all : (elt -> bool) -> t -> bool
    val exists : (elt -> bool) -> t -> bool
    val filter : (elt -> bool) -> t -> t
    val partition : (elt -> bool) -> t -> t * t
    val cardinal : t -> int
    val elements : t -> elt list
    val min_elt : t -> elt
    val max_elt : t -> elt
    val choose : t -> elt
    val split : elt -> t -> t * bool * t
end

(** **** I/O operations **** *)
(* Opens an input channel from a filename  *)
val open_in_file  : string -> in_channel

(* Opens an output channel from a filename. *)
val open_out_file : string -> out_channel

(* Reads a line from an input channel and return a string option.
   If end of file return None *) 
val read : in_channel -> string option

(* Reads the representation of a structured value, as produced by write_value 
   and returns the corresponding value. 
   Returns None if end of file or if cannot read from the in_channel. *)
val read_value : in_channel -> 'a option

val read_page : in_channel -> string option * string option

(* Write the string on the given output channel. *)
val write : out_channel -> string -> unit

(* Writes a value to a file *)
val write_value : out_channel -> 'a -> unit


(** **** Alias for several function and global variables **** *)
(* Alias for Printf.sprintf *)
val spf : ('a, unit, string) format -> 'a

(* Regular expression to parse a page *)
val page : Str.regexp

(* Regular expression to parse a link like [[link]] or [[link|bla]]*)
val link : Str.regexp

(* Name of the wiki pages*)
val fr_wiki : string

(* Name of the file which contains offsets list of pages *)
val offsets_list  : string

val cwiki : string

(** **** Useful functions for pre treatment operations **** *)
(* Calculates offsets of all page *)
val list_of_page_offsets : string -> int list

(* Creates the list of offsets and write in a file *)
val create_offsets_list : string -> unit


(** **** General useful functions **** *)
val list_to_queue : 'a list -> 'a Queue.t

val from_group : string -> int -> string

(* Replaces the string with a string list containing links and
   replaces all useless words by the number of occurrence that 
   exists between two links. For example: 
   split ["[[link1]]"; "w1"; "w2"; "[[link2]]"; "w3"; "[[link3]]"] returns
   ["link1"; "2"; "link2"; "1"; "link3"]
*)
val compact_string : string list -> string list

val partition : int -> int list -> int list list

(* TOUT CE QUI EST EN DESSOUS EST NOUVEAU *)

val nb_words : string -> int

val get_sresult : Str.split_result -> string

val get_link : Str.split_result list -> (string * Str.split_result list)

val compact : string list -> Str.split_result list -> string list
